<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/home
	 *	- or -  
	 * 		http://example.com/index.php/home/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
    function __construct()
    {
        parent::__construct();
		//Load Model
		$this->load->model('home_model');
		        	
		//Google Analytics ID
		$this->data['ga_id'] = 22;
						
		//Load News Script
		$this->data['js'][] = "homeScript.js";
		$this->data['css'][] = "homeStyle.css";		
    }

	/*ck_pushdown*/
	public function devzone($module=NULL)
	{
		//Load Module
		$this->data['module'] = $this->module();
		//Load Media Player
		$this->data['js'][] = "media/jwplayerx.js";
		//$this->data['js'][] = "media/6.12/jwplayer.js";
				
		$this->data['content'] = $this->router->class."/devzone";
		$this->load->view("templates/".$this->folder_templates."templates_devzone", $this->data);		
	}
	
	public function itzone()
	{
		//Load Module
		$this->data['module'] = $this->module('itzone');
		//Load Media Player
		$this->data['js'][] = "media/jwplayer.js";
				
		$this->data['content'] = $this->router->class."/itzone";
		$this->load->view("templates/".$this->folder_templates."templates_itzone", $this->data);	
	}
	
	/*Index*/
	public function index()
	{
		//Load Media Player
		if($this->agent->is_mobile()):
			$this->data['js'][] = "media/player.js";
		else:
			$this->data['js'][] = "media/jwplayerx.js";
		endif;
			
		//Load Colorbox
		$this->data['js'][]    = 'jquery.colorbox-min.js';
		$this->data['css'][]  = 'colorbox.css';

		//Load Multi Slider
		$this->data['js'][] = "jquery.multipleelements.cycle.min.js";
				
		//Load Module
		$this->data['module'] = $this->module();
		
		/*Hilight*/
		$this->data['dataHomeHilight'] = json_decode($this->db->get_where('module_page',array('page' => 'home'),1)->row()->json);
		
		/*Intrend*/
		if ( !$this->data['dataHomeIntrend'] = $this->memcache->get('dataHomeIntrend')):
			$this->data['dataHomeIntrend'] = $this->home_model->getHomeIntrend();
			$this->memcache->set('dataHomeIntrend', $this->data['dataHomeIntrend'], $this->memcache_time);
		endif;
		
		/*Thai*/
		if ( !$this->data['dataSongThai'] = $this->memcache->get('dataHomeSongThai')):
			$this->db->_protect_identifiers = FALSE;
			$this->data['dataSongThai'] = $this->db->select('t.song_id,j.song_name,t.views,k.chords_id')
			->join('song_info as j','j.song_id=t.song_id','INNER')
			->join('chords as k','k.song_id=t.song_id','LEFT')
			->group_by('t.song_id')
			->order_by('t.song_publish_date DESC,t.song_id DESC')
			->get_where('song as t',"t.media_type_id = 1 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.song_publish_date IS NULL OR t.song_publish_date < NOW())",16)
/*			->order_by('FIELD(t.song_id,15025) DESC,t.song_publish_date DESC,t.song_id DESC')
			->get_where('song as t',"t.song_id = 15025 OR t.media_type_id = 1 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.song_publish_date IS NULL OR t.song_publish_date < NOW())",16)*/
			->result();
			$this->db->_protect_identifiers = TRUE;
			foreach($this->data['dataSongThai'] as $value):
				$value->image = $this->db->select('j.album_file_name,j.album_file_ext')
				->join('album_info as j','j.album_id=t.album_id','INNER')
				->get_where('song_album as t',array('t.song_id' => $value->song_id,'t.is_default' => '1'),1)
				->row();
				$value->artist = $this->db->select('j.artist_id,j.artist_name')
				->join('artist_info as j','j.artist_id=t.artist_id','INNER')
				->get_where('song_artist as t',array('song_id' => $value->song_id,'t.is_default' => '1'))
				->result();
			endforeach;
			
			$this->memcache->set('dataHomeSongThai', $this->data['dataSongThai'], $this->memcache_time);
		endif;
		
		/*Inter*/
		if ( !$this->data['dataSongInter'] = $this->memcache->get('dataHomeSongInter')):	
			$this->data['dataSongInter'] = $this->db->select('t.song_id,j.song_name,t.views,k.chords_id')
			->join('song_info as j','j.song_id=t.song_id','INNER')
			->join('chords as k','k.song_id=t.song_id','LEFT')
			->group_by('t.song_id')
			->order_by('t.song_publish_date DESC,t.song_id DESC')
			->get_where('song as t',"t.media_type_id = 2 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.song_publish_date IS NULL OR t.song_publish_date < NOW())",16)->result();
			foreach($this->data['dataSongInter'] as $value):
				$value->image = $this->db->select('j.album_file_name,j.album_file_ext')
				->join('album_info as j','j.album_id=t.album_id','INNER')
				->get_where('song_album as t',array('t.song_id' => $value->song_id,'t.is_default' => '1'),1)
				->row();
				$value->artist = $this->db->select('j.artist_id,j.artist_name')
				->join('artist_info as j','j.artist_id=t.artist_id','INNER')
				->get_where('song_artist as t',array('song_id' => $value->song_id,'t.is_default' => '1'))
				->result();
			endforeach;
			$this->memcache->set('dataHomeSongInter', $this->data['dataSongInter'], $this->memcache_time);
		endif;
		
		/*Asian*/
		if ( !$this->data['dataSongAsian'] = $this->memcache->get('dataHomeSongAsian')):	
			$this->data['dataSongAsian'] = $this->db->select('t.song_id,j.song_name,t.views,k.chords_id')
			->join('song_info as j','j.song_id=t.song_id','INNER')
			->join('chords as k','k.song_id=t.song_id','LEFT')
			->group_by('t.song_id')
			->order_by('t.song_publish_date DESC,t.song_id DESC')
			->get_where('song as t',"t.media_type_id = 3 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.song_publish_date IS NULL OR t.song_publish_date < NOW())",16)->result();
			foreach($this->data['dataSongAsian'] as $value):
				$value->image = $this->db->select('j.album_file_name,j.album_file_ext')
				->join('album_info as j','j.album_id=t.album_id','INNER')
				->get_where('song_album as t',array('t.song_id' => $value->song_id,'t.is_default' => '1'),1)
				->row();
				$value->artist = $this->db->select('j.artist_id,j.artist_name')
				->join('artist_info as j','j.artist_id=t.artist_id','INNER')
				->get_where('song_artist as t',array('song_id' => $value->song_id,'t.is_default' => '1'))
				->result();
			endforeach;	
			$this->memcache->set('dataHomeSongAsian', $this->data['dataSongAsian'], $this->memcache_time);
		endif;
		
		/*Album Review*/	
		if ( !$this->data['dataAlbumReview'] = $this->memcache->get('dataHomeAlbumReview')):	
			$this->data['dataAlbumReview'] = $this->db->select('t.news_id,t.views,t.news_publish_date,j.news_subject,j.news_brief')
			->join('news_info as j','j.news_id=t.news_id','INNER')
			->order_by('t.news_publish_date','DESC')
			->get_where('news as t',"t.news_type_id = 5 AND t.is_publish = '1' AND t.is_review_hilight = '1'",20)
			->result();
			foreach($this->data['dataAlbumReview'] as $value):
				$value->image = $this->db->order_by("news_image_order ASC,news_image_id ASC")->get_where('news_image',array('news_id' => $value->news_id),1)->row();
			endforeach;
			$this->memcache->set('dataHomeAlbumReview', $this->data['dataAlbumReview'], $this->memcache_time);
		endif;
		
		/*Dream Ticket*/
		if ( !$this->data['dataHomeDreamTicket'] = $this->memcache->get('dataHomeDreamTicket')):
			$this->data['dataHomeDreamTicket'] = $this->db->select('t.song_id,j.song_name')
			->join('song_info as j','j.song_id=t.song_id','INNER')
			->join('song_artist as k','k.song_id=t.song_id','INNER')
			->join('artist as l','l.artist_id=k.artist_id','INNER')
			->order_by('t.song_id DESC')
			->get_where('song as t',array('t.is_show_new_released' => '1','l.is_show_dream_ticket' => '1','t.media_type_id' => 1),9)
			->result();
			foreach($this->data['dataHomeDreamTicket'] as $value):
				$value->artist = $this->db->select('j.artist_id,j.artist_name')
				->join('artist_info as j','j.artist_id=t.artist_id','INNER')
				->get_where('song_artist as t',array('t.song_id' => $value->song_id))
				->result();
				$value->image = $this->db->select('j.album_file_name,j.album_file_ext')
				->join('album_info as j','j.album_id=t.album_id','INNER')
				->get_where('song_album as t',array('t.song_id' => $value->song_id,'is_default' => '1'),1)
				->row();	
			endforeach;		
			//Cache Set
			$this->memcache->set('dataHomeDreamTicket', $this->data['dataHomeDreamTicket'], $this->memcache_time);
	 	endif;	
		
		/*Video Hilight*/
		if ( !$this->data['dataVideoHilight'] = $this->memcache->get('dataVideoHilight')):
			$this->db->_protect_identifiers = FALSE;
			$this->data['dataVideoHilight'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"t.is_publish = '1' AND t.is_show_hilight_on_home = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",5)->result();
			$this->db->_protect_identifiers = TRUE;
			foreach($this->data['dataVideoHilight'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;
			$this->memcache->set('dataVideoHilight', $this->data['dataVideoHilight'], $this->memcache_time);
		endif;		
		
		/*Video MV*/
		if ( !$this->data['dataVideoMV'] = $this->memcache->get('dataHomeVideoMV')):
			$this->db->_protect_identifiers = FALSE;
			$this->data['dataVideoMV'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"t.video_type_id = 1 AND t.is_publish = '1' AND t.is_show_new_released = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)		
/*			->order_by('FIELD(t.video_id,16322) DESC,t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"t.video_id = 16322 OR t.video_type_id = 1 AND t.is_publish = '1' AND t.is_show_new_released = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)*/
			->result();
			$this->db->_protect_identifiers = TRUE;
			foreach($this->data['dataVideoMV'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;
			$this->memcache->set('dataHomeVideoMV', $this->data['dataVideoMV'], $this->memcache_time);
		endif;
		
		/*Video InterView*/
		if ( !$this->data['dataVideoInterview'] = $this->memcache->get('dataHomeVideoInterview')):	
			$this->data['dataVideoInterview'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"video_type_id = 6 AND t.is_publish = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)->result();
			foreach($this->data['dataVideoInterview'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;	
			$this->memcache->set('dataHomeVideoInterview', $this->data['dataVideoInterview'], $this->memcache_time);
		endif;
		
		/*Video Concert*/
		if ( !$this->data['dataVideoConcert'] = $this->memcache->get('dataHomeVideoConcert')):	
			$this->data['dataVideoConcert'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"video_type_id = 4 AND t.is_publish = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)->result();
			foreach($this->data['dataVideoConcert'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;	
			$this->memcache->set('dataHomeVideoConcert', $this->data['dataVideoConcert'], $this->memcache_time);
		endif;
		
		/*Video News*/
		if ( !$this->data['dataVideoNews'] = $this->memcache->get('dataHomeVideoNews')):	
			/*$this->db->_protect_identifiers = FALSE;*/
			$this->data['dataVideoNews'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"video_type_id = 3 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)
/*			->order_by('FIELD(t.video_id,15902) DESC,t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"t.video_id = 15902 OR t.video_type_id = 3 AND t.is_publish = '1' AND t.is_show_new_released = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)*/
			->result();
			/*$this->db->_protect_identifiers = TRUE;*/
			foreach($this->data['dataVideoNews'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;
			$this->memcache->set('dataHomeVideoNews', $this->data['dataVideoNews'], $this->memcache_time);
		endif;
		
		/*You2play TV*/
		if ( !$this->data['dataVideoTv'] = $this->memcache->get('dataHomeVideoTv')):	
			$this->data['dataVideoTv'] = $this->db->select('t.video_id,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->join('video_type as k','k.video_type_id=t.video_type_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"k.is_tv_show = '1' AND is_show_new_released = '1' AND t.is_publish = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",4)->result();
			$this->memcache->set('dataHomeVideoTv', $this->data['dataVideoTv'], $this->memcache_time);
		endif;
		
		/*News*/
		if ( !$this->data['dataNews'] = $this->memcache->get('dataHomeNews')):
			$news_hilight_id = array();
			$dataNews = $this->db->select('t.news_id,j.news_subject')
			->join('news_info as j','j.news_id=t.news_id','INNER')
			->order_by('t.news_publish_date DESC,t.news_id DESC')
			->get_where('news as t',"t.is_main_hilight = '1' AND t.is_publish = '1' AND (t.news_publish_date IS NULL OR t.news_publish_date < NOW())",5)->result();
			foreach($dataNews as $value):
				$value->image = $this->db->select('news_file_name,news_file_ext')
				->order_by("news_image_order ASC,news_image_id ASC")
				->get_where('news_image as t',array('news_id' => $value->news_id),1)
				->row();
				$this->data['dataNews'][] = $value;
				$news_hilight_id[] = $value->news_id;
			endforeach;
			$dataNews = $this->db->select('t.news_id,j.news_subject')
			->join('news_info as j','j.news_id=t.news_id','INNER')
			->order_by('t.news_publish_date DESC,t.news_id DESC')
			->get_where('news as t',"t.is_publish = '1' AND (t.news_publish_date IS NULL OR t.news_publish_date < NOW()) AND t.news_id NOT IN (".implode(',',$news_hilight_id).")",6)->result();
			foreach($dataNews as $value):
				$value->image = $this->db->select('news_file_name,news_file_ext')
				->order_by("news_image_order ASC,news_image_id ASC")
				->get_where('news_image as t',array('news_id' => $value->news_id),1)
				->row();
				$this->data['dataNews'][] = $value;
			endforeach;		
			$this->memcache->set('dataHomeNews', $this->data['dataNews'], $this->memcache_time);	
		endif;
				
		/*Movie Showing*/
		if ( !$this->data['dataMovieShowing'] = $this->memcache->get('dataHomeMovieShowing')):	
			$this->data['dataMovieShowing'] = $this->db->select('t.movie_id,j.movie_name')
			->join('movie_info as j','j.movie_id=t.movie_id','INNER')
			->order_by('t.is_show_new_released DESC,t.movie_publish_date DESC')
			->get_where('movie as t',"t.is_publish = '1' AND t.movie_publish_date <= NOW() AND t.is_video_clip != '1'",4)->result();
			foreach($this->data['dataMovieShowing'] as $value):
				$value->image = $this->db->select('movie_file_name,movie_file_ext')
				->order_by("movie_image_order ASC,movie_image_id DESC")
				->get_where('movie_image as t',array('movie_id' => $value->movie_id),1)
				->row();
			endforeach;
			$this->memcache->set('dataHomeMovieShowing', $this->data['dataMovieShowing'], $this->memcache_time);
		endif;

		/*Movie Coming*/
		if ( !$this->data['dataMovieComing'] = $this->memcache->get('dataHomeMovieComing')):	
			$this->data['dataMovieComing'] = $this->db->select('t.movie_id,j.movie_name')
			->join('movie_info as j','j.movie_id=t.movie_id','INNER')
			->order_by('t.is_show_new_released DESC,t.movie_publish_date ASC')
			->get_where('movie as t',"t.is_publish = '1' AND t.movie_publish_date > NOW() AND t.is_video_clip != '1'",4)->result();
			foreach($this->data['dataMovieComing'] as $value):
				$value->image = $this->db->select('movie_file_name,movie_file_ext')
				->order_by("movie_image_order ASC,movie_image_id DESC")
				->get_where('movie_image as t',array('movie_id' => $value->movie_id),1)
				->row();
			endforeach;	
			$this->memcache->set('dataHomeMovieComing', $this->data['dataMovieComing'], $this->memcache_time);
		endif;
		
		/*Movie Clip*/
		if ( !$this->data['dataMovieClip'] = $this->memcache->get('dataHomeMovieClip')):	
			$this->data['dataMovieClip'] = $this->db->select('t.movie_id,j.movie_name')
			->join('movie_info as j','j.movie_id=t.movie_id','INNER')
			->order_by('t.movie_publish_date DESC,t.movie_id DESC')
			->get_where('movie as t',"t.is_publish = '1' AND t.is_video_clip = '1'",5)->result();
			foreach($this->data['dataMovieClip'] as $value):
				$value->image = $this->db->select('movie_file_name,movie_file_ext')
				->order_by("movie_image_order ASC,movie_image_id DESC")
				->get_where('movie_image as t',array('movie_id' => $value->movie_id),1)
				->row();
			endforeach;
			$this->memcache->set('dataHomeMovieClip', $this->data['dataMovieClip'], $this->memcache_time);
		endif;
		
		/*Fashion*/
		if ( !$this->data['dataFashion'] = $this->memcache->get('dataHomeFashion')):	
			$this->data['dataFashion'] = $this->db->select('fashion_id,fashion_name')
			->order_by('fashion_publish_date DESC,fashion_id DESC')
			->get_where('fashion',"is_publish = '1' AND is_main_hilight = '1' AND (fashion_publish_date IS NULL OR fashion_publish_date < NOW())",4)->result();
			foreach($this->data['dataFashion'] as $value):
				$value->image = $this->db->select('fashion_file_name,fashion_file_ext')
				->order_by("fashion_image_order ASC,fashion_image_id DESC")
				->get_where('fashion_image as t',array('fashion_id' => $value->fashion_id),1)
				->row();
			endforeach;
			$this->memcache->set('dataHomeFashion', $this->data['dataFashion'], $this->memcache_time);	
		endif;
				
		$this->data['content'] = $this->router->class."/".$this->router->method;
		$this->load->view("templates/".$this->folder_templates."templates.php", $this->data);
	}
	
	/*Home*/	 
	public function index_backup()
	{	
		//Cover Page
		//$this->cover_page();
		
		//Load Media Player
		if($this->agent->is_mobile()):
			$this->data['js'][] = "media/player.js";
		else:
			$this->data['js'][] = "media/jwplayerx.js";
		endif;		
			
		//Load Javascript
		$this->data['js'][] = "jquery.multipleelements.cycle.min.js";	
				
		//Load Module
		$this->data['module'] = $this->module('backup');
		
		//Load Ads
/*		$this->data['dataAds'] = array();
		$dataAds = $this->db->select('ads_id,ads_vast,ads_weight,limit_per_day')
		->get_where('ads',"start_date <= '".date('Y-m-d H:i:s')."' AND end_date > '".date('Y-m-d H:i:s')."' AND (ads_impression = 0 OR ads_impression > views) AND is_music = '1'")
		->result();
		foreach($dataAds as $key => $value):
			if(!empty($value->limit_per_day)):
				$impression_today = intval($this->db->select('SUM(views) as Views')
				->get_where('ads_static',"ads_id = ".$value->ads_id." AND event = 'Impression' AND DATE(date) = '".date('Y-m-d')."'")->row()->Views);
				if($impression_today < $value->limit_per_day):
					$this->data['dataAds'][] = $value;
				endif;			
			else:
				$this->data['dataAds'][] = $value;
			endif;
		endforeach;	*/
		
		/*Hilight*/
		$this->data['dataHomeHilight'] = json_decode($this->db->get_where('module_page',array('page' => 'home'),1)->row()->json);
		
		/*Thai*/
		if ( !$this->data['dataSongThai'] = $this->memcache->get('dataHomeSongThai')):
			$this->db->_protect_identifiers = FALSE;
			$this->data['dataSongThai'] = $this->db->select('t.song_id,j.song_name,t.views')
			->join('song_info as j','j.song_id=t.song_id','INNER')
			->order_by('t.song_publish_date DESC,t.song_id DESC')
			->get_where('song as t',"t.media_type_id = 1 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.song_publish_date IS NULL OR t.song_publish_date < NOW())",16)			
/*			->order_by('FIELD(t.song_id,15025) DESC,t.song_publish_date DESC,t.song_id DESC')
			->get_where('song as t',"t.song_id = 15025 OR t.media_type_id = 1 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.song_publish_date IS NULL OR t.song_publish_date < NOW())",16)*/
			->result();
			$this->db->_protect_identifiers = TRUE;
			foreach($this->data['dataSongThai'] as $value):
				$value->image = $this->db->select('j.album_file_name,j.album_file_ext')
				->join('album_info as j','j.album_id=t.album_id','INNER')
				->get_where('song_album as t',array('t.song_id' => $value->song_id,'t.is_default' => '1'),1)
				->row();
				$value->artist = $this->db->select('j.artist_id,j.artist_name')
				->join('artist_info as j','j.artist_id=t.artist_id','INNER')
				->get_where('song_artist as t',array('song_id' => $value->song_id,'t.is_default' => '1'))
				->result();
			endforeach;
			$this->memcache->set('dataHomeSongThai', $this->data['dataSongThai'], $this->memcache_time);
		endif;
		
		/*Inter*/
		if ( !$this->data['dataSongInter'] = $this->memcache->get('dataHomeSongInter')):	
			$this->data['dataSongInter'] = $this->db->select('t.song_id,j.song_name,t.views')
			->join('song_info as j','j.song_id=t.song_id','INNER')
			->order_by('t.song_publish_date DESC,t.song_id DESC')
			->get_where('song as t',"t.media_type_id = 2 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.song_publish_date IS NULL OR t.song_publish_date < NOW())",16)->result();
			foreach($this->data['dataSongInter'] as $value):
				$value->image = $this->db->select('j.album_file_name,j.album_file_ext')
				->join('album_info as j','j.album_id=t.album_id','INNER')
				->get_where('song_album as t',array('t.song_id' => $value->song_id,'t.is_default' => '1'),1)
				->row();
				$value->artist = $this->db->select('j.artist_id,j.artist_name')
				->join('artist_info as j','j.artist_id=t.artist_id','INNER')
				->get_where('song_artist as t',array('song_id' => $value->song_id,'t.is_default' => '1'))
				->result();
			endforeach;
			$this->memcache->set('dataHomeSongInter', $this->data['dataSongInter'], $this->memcache_time);
		endif;
		
		/*Asian*/
		if ( !$this->data['dataSongAsian'] = $this->memcache->get('dataHomeSongAsian')):	
			$this->data['dataSongAsian'] = $this->db->select('t.song_id,j.song_name,t.views')
			->join('song_info as j','j.song_id=t.song_id','INNER')
			->order_by('t.song_publish_date DESC,t.song_id DESC')
			->get_where('song as t',"t.media_type_id = 3 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.song_publish_date IS NULL OR t.song_publish_date < NOW())",16)->result();
			foreach($this->data['dataSongAsian'] as $value):
				$value->image = $this->db->select('j.album_file_name,j.album_file_ext')
				->join('album_info as j','j.album_id=t.album_id','INNER')
				->get_where('song_album as t',array('t.song_id' => $value->song_id,'t.is_default' => '1'),1)
				->row();
				$value->artist = $this->db->select('j.artist_id,j.artist_name')
				->join('artist_info as j','j.artist_id=t.artist_id','INNER')
				->get_where('song_artist as t',array('song_id' => $value->song_id,'t.is_default' => '1'))
				->result();
			endforeach;	
			$this->memcache->set('dataHomeSongAsian', $this->data['dataSongAsian'], $this->memcache_time);
		endif;
		
		/*Album Review*/	
		if ( !$this->data['dataAlbumReview'] = $this->memcache->get('dataHomeAlbumReview')):	
			$this->data['dataAlbumReview'] = $this->db->select('t.news_id,t.views,t.news_publish_date,j.news_subject,j.news_brief')
			->join('news_info as j','j.news_id=t.news_id','INNER')
			->order_by('t.news_publish_date','DESC')
			->get_where('news as t',"t.news_type_id = 5 AND t.is_publish = '1' AND t.is_review_hilight = '1'",20)
			->result();
			foreach($this->data['dataAlbumReview'] as $value):
				$value->image = $this->db->order_by("news_image_order ASC,news_image_id ASC")->get_where('news_image',array('news_id' => $value->news_id),1)->row();
			endforeach;
			$this->memcache->set('dataHomeAlbumReview', $this->data['dataAlbumReview'], $this->memcache_time);
		endif;
		
		/*Video MV*/
		if ( !$this->data['dataVideoMV'] = $this->memcache->get('dataHomeVideoMV')):
			$this->db->_protect_identifiers = FALSE;
			$this->data['dataVideoMV'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"t.video_type_id = 1 AND t.is_publish = '1' AND t.is_show_new_released = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)			
/*			->order_by('FIELD(t.video_id,15598) DESC,t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"t.video_id = 15598 OR t.video_type_id = 1 AND t.is_publish = '1' AND t.is_show_new_released = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)*/
			->result();
			$this->db->_protect_identifiers = TRUE;
/*			if(strtotime('2013-12-18') > time()): //Timer
				$ArrayObject = $this->data['dataVideoMV'];
				$countMv = 0;		
				$dataMVFix = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
				->join('video_info as j','j.video_id=t.video_id','INNER')
				->get_where('video as t',array('t.video_id' => 13674),1)->row();
				foreach($ArrayObject as $key => $value):
					if($countMv == 0) $this->data['dataVideoMV']{'0'} = $dataMVFix;
					if($dataMVFix->video_id == $value->video_id) continue;
					$countMv++;
					$this->data['dataVideoMV']{''.$countMv.''} = $value;
				endforeach;
			endif;*/
			foreach($this->data['dataVideoMV'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;
			$this->memcache->set('dataHomeVideoMV', $this->data['dataVideoMV'], $this->memcache_time);
		endif;
		
		/*Video InterView*/
		if ( !$this->data['dataVideoInterview'] = $this->memcache->get('dataHomeVideoInterview')):	
			$this->data['dataVideoInterview'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"video_type_id = 6 AND t.is_publish = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)->result();
			foreach($this->data['dataVideoInterview'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;	
			$this->memcache->set('dataHomeVideoInterview', $this->data['dataVideoInterview'], $this->memcache_time);
		endif;
		
		/*Video Concert*/
		if ( !$this->data['dataVideoConcert'] = $this->memcache->get('dataHomeVideoConcert')):	
			$this->data['dataVideoConcert'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"video_type_id = 4 AND t.is_publish = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)->result();
			foreach($this->data['dataVideoConcert'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;	
			$this->memcache->set('dataHomeVideoConcert', $this->data['dataVideoConcert'], $this->memcache_time);
		endif;
		
		/*Video News*/
		if ( !$this->data['dataVideoNews'] = $this->memcache->get('dataHomeVideoNews')):
			$this->db->_protect_identifiers = FALSE;
			$this->data['dataVideoNews'] = $this->db->select('t.video_id,t.is_relate_song,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
/*			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"video_type_id = 3 AND t.is_show_new_released = '1' AND t.is_publish = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)*/
			->order_by('FIELD(t.video_id,15902) DESC,t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"t.video_id = 15902 OR t.video_type_id = 3 AND t.is_publish = '1' AND t.is_show_new_released = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",12)
			->result();
			$this->db->_protect_identifiers = TRUE;
			foreach($this->data['dataVideoNews'] as $value):
				if($value->is_relate_song == '1'):
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('song_artist as k',"k.song_id=t.song_id AND is_default='1'",'INNER')
					->join('artist_info as j','j.artist_id=k.artist_id','INNER')
					->get_where('video_song as t',array('video_id' => $value->video_id))
					->result();				
				else:
					$value->artist = $this->db->select('j.artist_id,j.artist_name')
					->join('artist_info as j','j.artist_id=t.artist_id','INNER')
					->get_where('video_artist as t',array('video_id' => $value->video_id))
					->result();				
				endif;
			endforeach;
			$this->memcache->set('dataHomeVideoNews', $this->data['dataVideoNews'], $this->memcache_time);
		endif;
		
		/*You2play TV*/
		if ( !$this->data['dataVideoTv'] = $this->memcache->get('dataHomeVideoTv')):	
			$this->data['dataVideoTv'] = $this->db->select('t.video_id,j.video_name,t.views,j.video_thumb_name,j.video_thumb_ext')
			->join('video_info as j','j.video_id=t.video_id','INNER')
			->join('video_type as k','k.video_type_id=t.video_type_id','INNER')
			->order_by('t.video_publish_date DESC,t.video_id DESC')
			->get_where('video as t',"k.is_tv_show = '1' AND is_show_new_released = '1' AND t.is_publish = '1' AND (t.video_publish_date IS NULL OR t.video_publish_date < NOW())",4)->result();
			$this->memcache->set('dataHomeVideoTv', $this->data['dataVideoTv'], $this->memcache_time);
		endif;
		
		/*News*/
		if ( !$this->data['dataNews'] = $this->memcache->get('dataHomeNews')):
			$news_hilight_id = array();
			$dataNews = $this->db->select('t.news_id,j.news_subject')
			->join('news_info as j','j.news_id=t.news_id','INNER')
			->order_by('t.news_publish_date DESC,t.news_id DESC')
			->get_where('news as t',"t.is_main_hilight = '1' AND t.is_publish = '1' AND (t.news_publish_date IS NULL OR t.news_publish_date < NOW())",5)->result();
			foreach($dataNews as $value):
				$value->image = $this->db->select('news_file_name,news_file_ext')
				->order_by("news_image_order ASC,news_image_id ASC")
				->get_where('news_image as t',array('news_id' => $value->news_id),1)
				->row();
				$this->data['dataNews'][] = $value;
				$news_hilight_id[] = $value->news_id;
			endforeach;
			$dataNews = $this->db->select('t.news_id,j.news_subject')
			->join('news_info as j','j.news_id=t.news_id','INNER')
			->order_by('t.news_publish_date DESC,t.news_id DESC')
			->get_where('news as t',"t.is_publish = '1' AND (t.news_publish_date IS NULL OR t.news_publish_date < NOW()) AND t.news_id NOT IN (".implode(',',$news_hilight_id).")",6)->result();
			foreach($dataNews as $value):
				$value->image = $this->db->select('news_file_name,news_file_ext')
				->order_by("news_image_order ASC,news_image_id ASC")
				->get_where('news_image as t',array('news_id' => $value->news_id),1)
				->row();
				$this->data['dataNews'][] = $value;
			endforeach;		
			$this->memcache->set('dataHomeNews', $this->data['dataNews'], $this->memcache_time);	
		endif;
				
		/*Movie Showing*/
		if ( !$this->data['dataMovieShowing'] = $this->memcache->get('dataHomeMovieShowing')):	
			$this->data['dataMovieShowing'] = $this->db->select('t.movie_id,j.movie_name')
			->join('movie_info as j','j.movie_id=t.movie_id','INNER')
			->order_by('t.is_show_new_released DESC,t.movie_publish_date DESC')
			->get_where('movie as t',"t.is_publish = '1' AND t.movie_publish_date <= NOW() AND t.is_video_clip != '1'",4)->result();
			foreach($this->data['dataMovieShowing'] as $value):
				$value->image = $this->db->select('movie_file_name,movie_file_ext')
				->order_by("movie_image_order ASC,movie_image_id DESC")
				->get_where('movie_image as t',array('movie_id' => $value->movie_id),1)
				->row();
			endforeach;
			$this->memcache->set('dataHomeMovieShowing', $this->data['dataMovieShowing'], $this->memcache_time);
		endif;

		/*Movie Coming*/
		if ( !$this->data['dataMovieComing'] = $this->memcache->get('dataHomeMovieComing')):	
			$this->data['dataMovieComing'] = $this->db->select('t.movie_id,j.movie_name')
			->join('movie_info as j','j.movie_id=t.movie_id','INNER')
			->order_by('t.is_show_new_released DESC,t.movie_publish_date ASC')
			->get_where('movie as t',"t.is_publish = '1' AND t.movie_publish_date > NOW() AND t.is_video_clip != '1'",4)->result();
			foreach($this->data['dataMovieComing'] as $value):
				$value->image = $this->db->select('movie_file_name,movie_file_ext')
				->order_by("movie_image_order ASC,movie_image_id DESC")
				->get_where('movie_image as t',array('movie_id' => $value->movie_id),1)
				->row();
			endforeach;	
			$this->memcache->set('dataHomeMovieComing', $this->data['dataMovieComing'], $this->memcache_time);
		endif;
		
		/*Movie Clip*/
		if ( !$this->data['dataMovieClip'] = $this->memcache->get('dataHomeMovieClip')):	
			$this->data['dataMovieClip'] = $this->db->select('t.movie_id,j.movie_name')
			->join('movie_info as j','j.movie_id=t.movie_id','INNER')
			->order_by('t.movie_publish_date DESC,t.movie_id DESC')
			->get_where('movie as t',"t.is_publish = '1' AND t.is_video_clip = '1'",4)->result();
			foreach($this->data['dataMovieClip'] as $value):
				$value->image = $this->db->select('movie_file_name,movie_file_ext')
				->order_by("movie_image_order ASC,movie_image_id DESC")
				->get_where('movie_image as t',array('movie_id' => $value->movie_id),1)
				->row();
			endforeach;
			$this->memcache->set('dataHomeMovieClip', $this->data['dataMovieClip'], $this->memcache_time);
		endif;
		
		/*News Movie*/
		if ( !$this->data['dataNewsMovie'] = $this->memcache->get('dataHomeNewsMovie')):	
			$this->data['dataNewsMovie'] = $this->db->select('t.news_id,j.news_subject')
			->join('news_info as j','j.news_id=t.news_id','INNER')
			->order_by('t.news_publish_date DESC,t.news_id DESC')
			->get_where('news as t',"t.news_type_id = 6 AND t.is_publish = '1' AND (t.news_publish_date IS NULL OR t.news_publish_date < NOW())",3)->result();
			foreach($this->data['dataNewsMovie'] as $value):
				$value->image = $this->db->select('news_file_name,news_file_ext')
				->order_by("news_image_order ASC,news_image_id ASC")
				->get_where('news_image as t',array('news_id' => $value->news_id),1)
				->row();
			endforeach;	
			$this->memcache->set('dataHomeNewsMovie', $this->data['dataNewsMovie'], $this->memcache_time);
		endif;
		
		/*Fashion*/
		if ( !$this->data['dataFashion'] = $this->memcache->get('dataHomeFashion')):	
			$this->data['dataFashion'] = $this->db->select('fashion_id,fashion_name')
			->order_by('fashion_publish_date DESC,fashion_id DESC')
			->get_where('fashion',"is_publish = '1' AND is_main_hilight = '1' AND (fashion_publish_date IS NULL OR fashion_publish_date < NOW())",4)->result();
			foreach($this->data['dataFashion'] as $value):
				$value->image = $this->db->select('fashion_file_name,fashion_file_ext')
				->order_by("fashion_image_order ASC,fashion_image_id DESC")
				->get_where('fashion_image as t',array('fashion_id' => $value->fashion_id),1)
				->row();
			endforeach;
			$this->memcache->set('dataHomeFashion', $this->data['dataFashion'], $this->memcache_time);	
		endif;														
				
		$this->data['content'] = $this->router->class."/".$this->router->method;
		$this->load->view("templates/".$this->folder_templates."templates.backup.php", $this->data);
	}


	/*Career*/
	public function career()
	{
		$this->data['dataResults'] = $this->db->get_where('module_page',array('page' => 'career'),1)->row(); 
		
		$this->data['content'] = $this->router->class."/".$this->router->method;
		$this->load->view("templates/".$this->folder_templates."templates", $this->data);		
	}
	
	/*Advertising*/
	public function advertising()
	{
		$this->data['content'] = $this->router->class."/".$this->router->method;
		$this->load->view("templates/".$this->folder_templates."templates", $this->data);		
	}	
	
	public function live()
	{
		//Google Analytics ID
		$this->data['ga_id'] = 23;	
				
		//Load Media Player
		if($this->agent->is_mobile()):
			$this->data['js'][] = "media/player.js";
		else:
			$this->data['js'][] = "media/jwplayerx.js";
		endif;
		//Load Media Player
		//$this->data['js'][] = "media/jwplayer.js";		
		
		//Load Module
		$this->data['module'] = $this->module('search');
		$this->data['module_facebook_plugins_share'] = $this->module_facebook_plugins_share();
		$this->data['module_facebook_plugins_comment'] = $this->module_facebook_plugins_comment();
		
		//Load Ads
/*		$this->data['dataAds'] = array();
		$dataAds = $this->db->select('ads_id,ads_vast,ads_weight,limit_per_day')
		->get_where('ads',"start_date <= '".date('Y-m-d H:i:s')."' AND end_date > '".date('Y-m-d H:i:s')."' AND (ads_impression = 0 OR ads_impression > views) AND is_music = '1'")
		->result();
		foreach($dataAds as $key => $value):
			if(!empty($value->limit_per_day)):
				$impression_today = intval($this->db->select('SUM(views) as Views')
				->get_where('ads_static',"ads_id = ".$value->ads_id." AND event = 'Impression' AND DATE(date) = '".date('Y-m-d')."'")->row()->Views);
				if($impression_today < $value->limit_per_day):
					$this->data['dataAds'][] = $value;
				endif;			
			else:
				$this->data['dataAds'][] = $value;
			endif;
		endforeach;	*/				
				
		$this->data['seo_title'] = 'You2playTV Live - You2Play.com';
		$this->data['seo_description'] = 'ฟังเพลงออนไลน์ใหม่ล่าสุด ดู คลิปวีดีโอ video, MV, คอนเสิร์ต ดูภาพ แฟชั่นโชว์ แอบ Sexy ของ ดารา นักร้อง พร้อมประวัติ เนื้อเพลง';
		$this->data['seo_keyword'] = 'ฟังเพลงออนไลน์, เพลงใหม่ล่าสุด, คลิปวีดีโอ, เนื้อเพลง, ประวัติศิลปิน, video, MV, แฟชั่นโชว์';
		
		//GA Events
		$this->data['ga_event'] = 'CI-You2Play-Tv';
		
		$this->data['content'] = $this->router->class."/".$this->router->method;
		$this->load->view("templates/".$this->folder_templates."templates", $this->data);		
	}
	
	/*Embed*/
	public function embed($media_type = NULL,$id = NULL)
	{
		if(empty($media_type)) redirect('');
		switch($media_type):
			case 'music':
				if(!empty($id)):
					$is_exist = $this->db->from('song')->where(array('song_id' => $id))->count_all_results();
					if(!empty($is_exist)):
						$dataSong = $this->db->select('t.song_id,j.song_name,j.song_file_name,j.song_file_ext,t.create_date')
						->join('song_info as j','j.song_id=t.song_id','INNER')
						->get_where('song as t',array('t.song_id' => $id),1)->row();
						$dataSong->artist = $this->db->select('j.artist_name')
						->join('artist_info as j','j.artist_id=t.artist_id','INNER')
						->get_where('song_artist as t',array('song_id' => $id,'is_default' => '1'))
						->result();
						$artist_name_arr = array();
						foreach($dataSong->artist as $value):
							$artist_name_arr[] = $value->artist_name;
						endforeach;
						$dataSong->album = $this->db->select('j.album_file_name,j.album_file_ext')
						->join('album_info as j','j.album_id=t.album_id','INNER')
						->get_where('song_album as t',array('song_id' => $id,'is_default' => '1'),1)
						->row();
						
						$data = array(
							'mp3_url' => ''.other_asset_url('uploads/song/files/'.date('Y/m/d',strtotime($dataSong->create_date)).'/'.$dataSong->song_file_name.'.'.$dataSong->song_file_ext).'',
							'title' => ''.$dataSong->song_name.'',
							'seo_title' => seo_url($dataSong->song_name),
							'artist_name' => ''.implode('/',$artist_name_arr).'',
							'album_thumb' => ''.other_asset_url('uploads/album/images/120x120/'.$dataSong->album->album_file_name.'.'.$dataSong->album->album_file_ext).'',
							'mobile' => '',
							'digital' => '',
							'physical' => '',
							'item_type' => 'music',
							'add_to_playlist' => 'false',
						);	
						echo json_encode($data);
						exit;				
					endif;
				endif;
			break;
		endswitch;
	}
	
	/*player*/
	public function player($media_type = NULL,$id = NULL,$sequence = NULL)
	{
		//Load Media Player
		if($this->agent->is_mobile()):
			$this->data['js'][] = "media/player.js";
		else:
			$this->data['js'][] = "media/jwplayerx.js";
		endif;	
				
		if(empty($media_type) || empty($id)) redirect('');
		switch($media_type):
			case 'music':
				$is_exist = $this->db->from('song as t')
				->join('song_info as j','j.song_id=t.song_id','INNER')
				->where(array('t.song_id' => $id,'t.is_publish' => '1'))->count_all_results();
				if(empty($is_exist)) redirect('');
				$this->data['dataResult'] = $this->db->select('t.song_id as media_id,t.create_date,j.song_name,j.song_file_name,j.song_file_ext,j.song_embed')
				->join('song_info as j','j.song_id=t.song_id','INNER')
				->get_where('song as t',array('t.song_id' => $id,'t.is_publish' => '1'),1)
				->row();
				$this->data['dataResult']->album = $this->db->select('j.album_id,j.album_name,j.album_file_name,j.album_file_ext')
				->join('album_info as j','j.album_id=t.album_id','INNER')
				->get_where('song_album as t',array('t.song_id' => $this->data['dataResult']->media_id,'is_default' => '1'),1)
				->row();
				//$this->data['dataResult']->file_url = other_asset_url('uploads/song/files/'.date('Y/m/d',strtotime($this->data['dataResult']->create_date)).'/'.$this->data['dataResult']->song_file_name.'.'.$this->data['dataResult']->song_file_ext);
				$this->data['dataResult']->file_url = 'http://vstatic.you2play.com/2013/assets/uploads/song/files/'.date('Y/m/d',strtotime($this->data['dataResult']->create_date)).'/'.$this->data['dataResult']->song_file_name.'.'.$this->data['dataResult']->song_file_ext;
				$this->data['dataResult']->image_url = other_asset_url('uploads/album/images/original/'.@$this->data['dataResult']->album->album_file_name.'.'.@$this->data['dataResult']->album->album_file_ext);
				$this->data['dataResult']->media_type = 'music';
				//Google Analytics ID
				$this->data['ga_id'] = 11;
				//GA Events
				$this->data['ga_event'] = 'Embed-Music-ID-'.$id.'-'.seo_url($this->data['dataResult']->song_name);
			break;
			case 'video':
				$is_exist = $this->db->from('video as t')
				->join('video_info as j','j.video_id=t.video_id','INNER')
				->where(array('t.video_id' => $id,'t.is_publish' => '1'))->count_all_results();
				if(empty($is_exist)) redirect('');
				$this->data['dataResult'] = $this->db->select('t.video_id as media_id,t.create_date,j.video_name,j.video_thumb_name,j.video_thumb_ext,j.video_file_name,j.video_file_ext,j.video_embed')
				->join('video_info as j','j.video_id=t.video_id','INNER')
				->get_where('video as t',array('t.video_id' => $id,'t.is_publish' => '1'),1)
				->row();
				//$this->data['dataResult']->file_url = other_asset_url('uploads/video/files/'.date('Y/m/d',strtotime($this->data['dataResult']->create_date)).'/'.$this->data['dataResult']->video_file_name.'.'.$this->data['dataResult']->video_file_ext);
				$this->data['dataResult']->file_url = 'http://vstatic.you2play.com/2013/assets/uploads/video/files/'.date('Y/m/d',strtotime($this->data['dataResult']->create_date)).'/'.$this->data['dataResult']->video_file_name.'.'.$this->data['dataResult']->video_file_ext;
				$this->data['dataResult']->image_url = other_asset_url('uploads/video/images/original/'.@$this->data['dataResult']->video_thumb_name.'.'.@$this->data['dataResult']->video_thumb_ext);
				$this->data['dataResult']->media_type = 'video';
				//Google Analytics ID
				$this->data['ga_id'] = 13;
				//GA Events
				$this->data['ga_event'] = 'Embed-Video-ID-'.$id.'-'.seo_url($this->data['dataResult']->video_name);				
			break;
			case 'movie':
				$is_exist = $this->db->from('movie as t')
				->join('movie_info as j','j.movie_id=t.movie_id','INNER')
				->where(array('t.movie_id' => $id,'t.is_publish' => '1'))->count_all_results();
				if(empty($is_exist) || empty($sequence) || intval($sequence) > 3) redirect('');	
				$this->data['dataResult'] = $this->db->select('t.movie_id as media_id,t.create_date,j.movie_name,j.movie_file_name'.$sequence.',j.movie_file_ext'.$sequence.'')
				->join('movie_info as j','j.movie_id=t.movie_id','INNER')
				->get_where('movie as t',array('t.movie_id' => $id,'t.is_publish' => '1'),1)
				->row();
				$this->data['dataResult']->file_url = other_asset_url('uploads/movie/files/'.date('Y/m/d',strtotime($this->data['dataResult']->create_date)).'/'.$this->data['dataResult']->{'movie_file_name'.$sequence}.'.'.$this->data['dataResult']->{'movie_file_ext'.$sequence});
				$dataImages = $this->db->select('movie_file_name,movie_file_ext')
				->get_where('movie_image',array('movie_id' => $id,'movie_image_order' => 0),1)
				->row();
				$this->data['dataResult']->image_url = other_asset_url('uploads/movie/images/original/'.@$dataImages->movie_file_name.'.'.@$dataImages->movie_file_ext);
				$this->data['dataResult']->media_type = 'movie';
				//Google Analytics ID
				$this->data['ga_id'] = 15;
				//GA Events
				$this->data['ga_event'] = 'Embed-Movie-ID-'.$id.'-'.seo_url($this->data['dataResult']->movie_name);						
			break;					
		endswitch;
		$this->load->view("templates/".$this->folder_templates."templates_player", $this->data);			
	}	
	
	public function comingsoon()
	{
		$this->data['content'] = $this->router->class."/".$this->router->method;
		$this->load->view("templates/".$this->folder_templates."templates", $this->data);		
	}


	public function policy($mode = NULL)
	{
		if(empty($mode)) $this->page_missing();
		switch($mode):
			case 'facebook':
				$this->data['content'] = $this->router->class."/".$this->router->method."/".$mode;
				$this->load->view("templates/".$this->folder_templates."templates", $this->data);			
			break;		
			case 'website':
				$this->data['content'] = $this->router->class."/".$this->router->method."/".$mode;
				$this->load->view("templates/".$this->folder_templates."templates", $this->data);			
			break;
		endswitch;		
	}
	
	public function member($module=NULL)
	{
		$this->load->model('member_model');
		$this->data['js'][] = "jquery.validate.min.js";
		$this->data['css'][] = "memberStyle.css";
		
		switch($module):
			case 'register':
			
				/*if(isset($_POST) && !empty($_POST)):
					$this->member_model->member_register();
					//redirect($this->session->userdata('returnUrl'));
				endif;*/
				
				$this->data['content'] = $this->router->class."/register";
				$this->load->view("templates/".$this->folder_templates."templates", $this->data);
			break;
			
			case 'result':
				$this->data['content'] = $this->router->class."/result";
				$this->load->view("templates/".$this->folder_templates."templates", $this->data);
			break;
			
			case 'edit_profile':
			
				/*if(isset($_POST) && !empty($_POST)):
					$this->member_model->member_edit_profile();
					//redirect($this->session->userdata('returnUrl'));
				endif;*/
				
				$this->data['content'] = $this->router->class."/edit_profile";
				$this->load->view("templates/".$this->folder_templates."templates", $this->data);
			break;
			
			case 'login':
				$this->data['content'] = $this->router->class."/login";
				$this->load->view("templates/".$this->folder_templates."templates", $this->data);
			break;
			
			case 'ajax_username_valid':
				$this->member_model->ajax_username_valid();				
			break;
			
			case 'ajax_email_valid':
				$this->member_model->ajax_email_valid();			
			break;
			
			case 'ajax_id_card_valid':
				$this->member_model->ajax_id_card_valid();			
			break;

			default:
				//สมัครสมาชิกอยู่หรือเปล่า ->ไม่ -> register
				redirect('member/login');
				//login อยู่ ให้ไป
				redirect('member/edit_profile');
		endswitch;
	}
	
	/*You2Play Party*/
	public function you2playparty()
	{
		$this->data['css'] = array('you2playparty/defaultStyle.min.css');
		$this->data['js'] = array();
		$this->data['js'][] = "jquery-1.8.3.min.js";
		$this->data['js'][] = "jquery.multipleelements.cycle.min.js";
		$this->data['js'][] = "media/jwplayer.js";
		//Load ColorBox
		$this->data['js'][] = "jquery.colorbox-min.js";
		$this->data['css'][] = "colorbox.css";			
		$this->load->view($this->router->class."/".$this->router->method, $this->data);		
	}
	
	/*Singha*/
	public function singhabeerpark2014()
	{
		//Directory Helper
		$this->load->helper('directory');
	
			
		/*Get Images*/
		$upload_singha_path = $this->upload_folder.'../images/home/singha/gallery/';
		$map = directory_map($upload_singha_path, 1);
		$this->data['dataImages'] = array();
		if(!empty($map)) foreach($map as $key => $filename):
			$this->data['dataImages'][] = $filename;
			if(file_exists(realpath($this->upload_folder.'singhabeerpark2014/images/original/'.$filename))) continue;
			//Generate Thumnail
			imageResize(array(
				'source_image' => $upload_singha_path.$filename,
				'new_path' => $this->upload_folder.'singhabeerpark2014/images/',
				'dimension' => array(											
					array(
						'width' => 220,
						'height' => 125
					)				
				),
				'watermark' => $this->upload_folder.'watermark/watermark.png'
			),substr($filename,0,-4));
		endforeach;
				
		$this->data['css'][] = "singha/singha.css";
		$this->data['js'][] = "jquery.multipleelements.cycle.min.js";
		//Load Media Player
		if($this->agent->is_mobile()):
			$this->data['js'][] = "media/player.js";
		else:
			$this->data['js'][] = "media/jwplayerx.js";
		endif;
		//Load ColorBox
		$this->data['js'][] = "jquery.colorbox-min.js";
		$this->data['css'][] = "colorbox.css";
		
		//Set Video
		$this->data['dataVideo'] = array(
			array('title' => 'Jetset\'er @ลานเบียร์สิงห์ CTW (11 ธ.ค. 57)','embeded' => 'E2s40_ETyqU'),
			array('title' => 'ตู่ ภพธร @ลานเบียร์สิงห์ CTW (9 ธ.ค. 57)','embeded' => 'r-_AS-fsrf4'),
			array('title' => 'The Dey @ลานเบียร์สิงห์ CDC (28 พ.ย. 57)','embeded' => 'Q3KqM7Z0CAA'),
			array('title' => 'P.O.P @ลานเบียร์สิงห์ CTW (22 พ.ย 57)','embeded' => 'hyIUQFtDwHk'),
			array('title' => 'Zeal @ลานเบียร์สิงห์ CTW (20 พ.ย 57)','embeded' => 'Hk_eOctRNl4'),
			array('title' => 'Lomosonic @ลานเบียร์สิงห์ CTW (18 พ.ย. 57)','embeded' => '-7ed5tf0PTQ'),
			array('title' => 'แกงส้ม ธนทัต @ลานเบียร์สิงห์ CTW (15 พ.ย. 57)','embeded' => 'hYcsd02ItGU'),
			array('title' => 'นัน เทม ถังเบียร์ AF @ลานเบียร์สิงห์ CTW (07 พ.ย 57)','embeded' => 'DO53C9NBGgQ'),
			array('title' => 'เบน ชลาทิศ @ลานเบียร์สิงห์ CTW (4 ธ.ค 57)','embeded' => '0q5wtAVSUjY'),
			array('title' => 'ทรงไทย @ลานเบียร์สิงห์ CDC (03 ธ.ค. 57)','embeded' => 'Hr2jujK3n2s'),
			array('title' => 'The Original Band @ลานเบียร์สิงห์ สยามดิสคัฟเวอรี่ (2 ธ.ค. 
57)','embeded' => 'j3zSy4RbX5Q'),
			array('title' => 'แหนม และ Season Five @ ลานเบียร์สิงห์ CTW (2 ธ.ค. 57)','embeded' => 'NE4RG8uPzuA')
		);
		
		//Set Time To STREAM
		$showtime = array(
			array('showtime' => strtotime("2014-11-30 10:45:00"))
		);
		
		//Check Time To Stream
		$this->data['is_stream'] = true;
		$duration_showtime = 120; //in minutes
		foreach($showtime as $value):
			$diff_time = ((time() - $value['showtime']) / 60);
			if(($diff_time < $duration_showtime) && ($diff_time > 0)):
				$this->data['is_stream'] = true;
			endif;
		endforeach;
		
		//Settings SEO
		$this->data['seo_title'] = 'ถ่ายทอดสด! คอนเสิร์ตการแสดงสด ณ ลานเบียร์สิงห์ ที่นี่ที่เดียว! | You2Play.com';
		$this->data['seo_keyword'] = 'เบียร์สิงห์, คอนเสิร์ตสิงห์, การแสดงสด, ถ่ายทอดสด';
		$this->data['seo_description'] = 'ถ่ายทอดสด! คอนเสิร์ตการแสดงสด ณ ลานเบียร์สิงห์ ที่นี่ที่เดียว! | You2Play.com';
		$this->data['fb_image'] = image_asset_url('home/singha/fb_image.jpg');
		
		$this->data['content'] = $this->router->class."/".$this->router->method;
		$this->load->view("templates/".$this->folder_templates."templates.php", $this->data);
	}
	
	public function singhabeerpark2014_test()
	{
		$this->data['css'][] = "singha/singha.css";
		$this->data['js'][] = "jquery.multipleelements.cycle.min.js";
		//Load Media Player
		if($this->agent->is_mobile()):
			$this->data['js'][] = "media/player.js";
		else:
			$this->data['js'][] = "media/jwplayerx.js";
		endif;
		//Load ColorBox
		$this->data['js'][] = "jquery.colorbox-min.js";
		$this->data['css'][] = "colorbox.css";
		
		//Set Time To STREAM
		$showtime = array(
			array('showtime' => strtotime("2014-11-30 10:45:00"))
		);
		
		//Check Time To Stream
		$this->data['is_stream'] = true;
		$duration_showtime = 120; //in minutes
		foreach($showtime as $value):
			$diff_time = ((time() - $value['showtime']) / 60);
			if(($diff_time < $duration_showtime) && ($diff_time > 0)):
				$this->data['is_stream'] = true;
			endif;
		endforeach;
		
		//Settings SEO
		$this->data['seo_title'] = 'ถ่ายทอดสด! คอนเสิร์ตการแสดงสด ณ ลานเบียร์สิงห์ ที่นี่ที่เดียว! | You2Play.com';
		$this->data['seo_keyword'] = 'เบียร์สิงห์, คอนเสิร์ตสิงห์, การแสดงสด, ถ่ายทอดสด';
		$this->data['seo_description'] = 'ถ่ายทอดสด! คอนเสิร์ตการแสดงสด ณ ลานเบียร์สิงห์ ที่นี่ที่เดียว! | You2Play.com';
		$this->data['fb_image'] = image_asset_url('home/singha/fb_image.jpg');
		
		$this->data['content'] = $this->router->class."/".$this->router->method;
		$this->load->view("templates/".$this->folder_templates."templates.php", $this->data);
	}	
		
	/*Rss Feed*/
	public function rss($category = NULL)
	{
		switch($category):
			case 'music':
				$this->data['title'] = "Music";
				$this->data['title_url'] = $this->data['music_url'];
				$this->data['dataResult'] = $this->db->select('t.song_id as id,t.song_publish_date,j.song_name as title,j.song_description as description,j.song_tag as tag')
				->join('song_info as j','j.song_id=t.song_id','INNER')
				->order_by('t.song_id','DESC')
				->get_where('song as t',array('is_publish' => '1'),20)
				->result();
				foreach($this->data['dataResult'] as $value):
					$value->link = $this->data['title_url'].'play/'.$value->id.'-'.seo_url($value->title);
					$dataImage = @$this->db->select('j.album_file_name,j.album_file_ext')
					->join('album_info as j','j.album_id=t.album_id','INNER')
					->get_where('song_album as t',array('t.song_id' => $value->id),1)
					->row();
					if(!empty($dataImage)) $value->thumbnail = other_asset_url('uploads/album/images/original/'.$dataImage->album_file_name.'.'.$dataImage->album_file_ext);
					$value->pubDate = date("D, d M Y H:i:s T", strtotime($value->song_publish_date));
				endforeach;				
			break;
			case 'video':
				$this->data['title'] = "Video";
				$this->data['title_url'] = $this->data['video_url'];
				$this->data['dataResult'] = $this->db->select('t.video_id as id,t.video_publish_date,j.video_name as title,j.video_description as description,j.video_thumb_name,j.video_thumb_ext,j.video_tag as tag')
				->join('video_info as j','j.video_id=t.video_id','INNER')
				->order_by('t.video_id','DESC')
				->get_where('video as t',array('is_publish' => '1'),20)
				->result();
				foreach($this->data['dataResult'] as $value):
					$value->link = $this->data['title_url'].'play/'.$value->id.'-'.seo_url($value->title);
					$value->thumbnail = other_asset_url('uploads/video/images/original/'.$value->video_thumb_name.'.'.$value->video_thumb_ext);
					$value->pubDate = date("D, d M Y H:i:s T", strtotime($value->video_publish_date));
				endforeach;			
			break;
			case 'movie':
				$this->data['title'] = "Movie";
				$this->data['title_url'] = $this->data['movie_url'];
				$this->data['dataResult'] = $this->db->select('t.movie_id as id,t.movie_publish_date,j.movie_name as title,j.movie_description as description,j.movie_tag as tag')
				->join('movie_info as j','j.movie_id=t.movie_id','INNER')
				->order_by('t.movie_id','DESC')
				->get_where('movie as t',array('is_publish' => '1'),20)
				->result();
				foreach($this->data['dataResult'] as $value):
					$value->link = $this->data['title_url'].'play/'.$value->id.'-'.seo_url($value->title);
					$dataImage = @$this->db->select('movie_file_name,movie_file_ext')
					->order_by('movie_image_order ASC,movie_image_id ASC')
					->get_where('movie_image',array('movie_id' => $value->id),1)
					->row();
					if(!empty($dataImage)) $value->thumbnail = other_asset_url('uploads/movie/images/original/'.$dataImage->movie_file_name.'.'.$dataImage->movie_file_ext);
					$value->pubDate = date("D, d M Y H:i:s T", strtotime($value->movie_publish_date));
				endforeach;				
			break;
			case 'news':
				$this->data['title'] = "News";
				$this->data['title_url'] = $this->data['news_url'];
				$this->data['dataResult'] = $this->db->select('t.news_id as id,t.news_publish_date,j.news_subject as title,j.news_brief as description,j.news_tag as tag')
				->join('news_info as j','j.news_id=t.news_id','INNER')
				->order_by('t.news_id','DESC')
				->get_where('news as t',array('is_publish' => '1'),20)
				->result();
				foreach($this->data['dataResult'] as $value):
					$value->link = $this->data['title_url'].'archives/'.$value->id.'-'.seo_url($value->title);
					$dataImage = @$this->db->select('news_file_name,news_file_ext')
					->order_by('news_image_order ASC,news_image_id ASC')
					->get_where('news_image',array('news_id' => $value->id),1)
					->row();
					if(!empty($dataImage)) $value->thumbnail = other_asset_url('uploads/news/images/original/'.$dataImage->news_file_name.'.'.$dataImage->news_file_ext);
					$value->pubDate = date("D, d M Y H:i:s T", strtotime($value->news_publish_date));
				endforeach;			
			break;											
			case 'chord':
				$this->data['title'] = "Chord";
				$this->data['title_url'] = $this->data['chord_url'];
				$this->data['dataResult'] = $this->db->select('t.chords_id as id,t.chords_publish_date,t.song_id,CONCAT(j.song_name," - ",j.artist_name) as title,CONCAT(j.song_name," - ",j.artist_name) as description,album_file_name,album_file_ext,j.chords_tag as tag',FALSE)
				->join('chords_info as j','j.chords_id=t.chords_id','INNER')
				->order_by('t.chords_id','DESC')
				->get_where('chords as t',array('is_publish' => '1'),20)
				->result();
				foreach($this->data['dataResult'] as $value):
					$value->link = $this->data['title_url'].'play/'.$value->id.'-'.seo_url($value->title);
					if(!empty($value->song_id)):
						$dataImage = $this->db->select('j.album_file_name,j.album_file_ext')
						->join('album_info as j','j.album_id=t.album_id','INNER')
						->get_where('song_album as t',array('song_id' => $value->song_id,'is_default' => '1'),1)
						->row();
						if(!empty($dataImage)):
							$value->thumbnail = other_asset_url('uploads/album/images/original/'.$dataImage->album_file_name.'.'.$dataImage->album_file_ext);
						endif;
					else:
						$value->thumbnail = other_asset_url('uploads/chords/images/original/'.$value->album_file_name.'.'.$value->album_file_ext);
					endif;
					$value->pubDate = date("D, d M Y H:i:s T", strtotime($value->chords_publish_date));
				endforeach;				
			break;
			case 'artist':
				$this->data['title'] = "Artist";
				$this->data['title_url'] = $this->data['artist_url'];
				$this->data['dataResult'] = $this->db->select('t.artist_id as id,t.artist_publish_date,j.artist_name as title,j.artist_short_desc as description,j.artist_tag as tag')
				->join('artist_info as j','j.artist_id=t.artist_id','INNER')
				->order_by('t.artist_id','DESC')
				->get_where('artist as t',array('is_publish' => '1'),20)
				->result();
				foreach($this->data['dataResult'] as $value):
					$value->link = $this->data['title_url'].'summary/'.$value->id.'-'.seo_url($value->title);
					$dataImage = @$this->db->select('artist_file_name,artist_file_ext')
					->order_by('artist_image_order ASC,artist_image_id ASC')
					->get_where('artist_image',array('artist_id' => $value->id),1)
					->row();
					if(!empty($dataImage)) $value->thumbnail = other_asset_url('uploads/artist/images/original/'.$dataImage->artist_file_name.'.'.$dataImage->artist_file_ext);
					$value->pubDate = date("D, d M Y H:i:s T", strtotime($value->artist_publish_date));
				endforeach;					
			break;
			case 'fashion':
				$this->data['title'] = "Fashion";
				$this->data['title_url'] = $this->data['fashion_url'];
				$this->data['dataResult'] = $this->db->select('fashion_id as id,fashion_publish_date,fashion_name as title,fashion_brief as description,fashion_tag as tag')	
				->order_by('fashion_id','DESC')	
				->get_where('fashion',array('is_publish' => '1'),20)
				->result();
				foreach($this->data['dataResult'] as $value):
					$value->link = $this->data['title_url'].'archives/'.$value->id.'-'.seo_url($value->title);
					$dataImage = @$this->db->select('fashion_file_name,fashion_file_ext')
					->order_by('fashion_image_order ASC,fashion_image_id ASC')
					->get_where('fashion_image',array('fashion_id' => $value->id),1)
					->row();
					if(!empty($dataImage)) $value->thumbnail = other_asset_url('uploads/fashion/images/original/'.$dataImage->fashion_file_name.'.'.$dataImage->fashion_file_ext);
					$value->pubDate = date("D, d M Y H:i:s T", strtotime($value->fashion_publish_date));
				endforeach;
			break;
			case 'gallery':
				$this->data['title'] = "Gallery";
				$this->data['title_url'] = $this->data['gallery_url'];
				$this->data['dataResult'] = $this->db->select('gallery_id as id,gallery_publish_date,gallery_name as title,gallery_brief as description,gallery_tag as tag')	
				->order_by('gallery_id','DESC')	
				->get_where('gallery',array('is_publish' => '1'),20)
				->result();
				foreach($this->data['dataResult'] as $value):
					$value->link = $this->data['title_url'].'archives/'.$value->id.'-'.seo_url($value->title);
					$dataImage = @$this->db->select('gallery_file_name,gallery_file_ext')
					->order_by('gallery_image_order ASC,gallery_image_id ASC')
					->get_where('gallery_image',array('gallery_id' => $value->id),1)
					->row();
					if(!empty($dataImage)) $value->thumbnail = other_asset_url('uploads/gallery/images/original/'.$dataImage->gallery_file_name.'.'.$dataImage->gallery_file_ext);
					$value->pubDate = date("D, d M Y H:i:s T", strtotime($value->gallery_publish_date));
				endforeach;			
			break;								
			default:
				$this->page_missing();
		endswitch;
		$this->load->view("templates/".$this->folder_templates."templates_rss", $this->data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */